package br.com.minhascontas.controller;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import br.com.example.minhascontas.R;
import br.com.minhascontas.model.Lancamentos;

public class ListViewLancamentos extends BaseAdapter {
	
	private Context context;
	private List<Lancamentos> clsLancamentos;
	
	public ListViewLancamentos(Context context, List<Lancamentos> clsLancamentos){
		this.context = context;
		this.clsLancamentos = clsLancamentos;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return clsLancamentos.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return clsLancamentos.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Lancamentos clsLancamento = clsLancamentos.get(position);
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View v = inflater.inflate(R.layout.listview_lancamento, null);
		
		TextView txtGrupo = (TextView) v.findViewById(R.id.txtGrupo);
		TextView txtValor = (TextView) v.findViewById(R.id.txtValor);
		TextView txtSubGrupo = (TextView) v.findViewById(R.id.txtSubGrupo);
		
		ImageView image = (ImageView) v.findViewById(R.id.icon);
		image.setImageResource(R.drawable.ic_launcher);
		
		txtGrupo.setText(clsLancamento.getNomeGrupo());
		txtValor.setText("R$" +Double.toString(clsLancamento.getValor()));
		txtSubGrupo.setText(clsLancamento.getNomeItemGrupo());
		
		
		
		return v;
	}

}
